<template>
  <div>
      商品编号/商品名称/规格/属性
      <el-input style="margin: 10px; width: 100px" v-model="form.productCodeOrName"></el-input>
      交货日期
        <el-date-picker
          v-model="form.deliveryDate"
          type="daterange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          >
        </el-date-picker>
      销售订单号
      <el-input style="margin: 10px; width: 100px" v-model="form.salesOrderNumber"></el-input>
      客户
        <el-input style="margin: 10px; width: 100px" v-model="form.customer"></el-input>
        <el-button style="margin-left: -10px;" @click="dialogVisible2 = true">...</el-button>
        <br>
      默认供应商
        <el-input style="margin: 10px; width: 100px" v-model="form.pro"></el-input>
        <el-button style="margin-left: -10px;" @click="dialogVisible = true">...</el-button>
        品牌
        <el-input style="margin: 10px; width: 100px" v-model="form.brand"></el-input>
        <el-checkbox v-model="form.showAvailableInventory">显示可用库存</el-checkbox>
        <el-checkbox v-model="form.excludeCompletedOrders">销售订单范围：已采购完订单不显示</el-checkbox>&nbsp;
      <el-button type="primary" @click="handleSubmit">查询</el-button>

      
    <el-divider></el-divider>
    <div style="float: right; margin-bottom: 10px">
      <el-button  @click="goto('Order')">生成购货订单</el-button>
      <el-button >导出</el-button>
    </div>

<el-table :data="orders" style="width: 100%">
  <el-table-column prop="documentNum" label="销货订单信息"> 
    <el-table-column prop="goodcode" label="商品编号"></el-table-column>
    <el-table-column prop="goodname" label="商品名称"></el-table-column>
    <el-table-column prop="unitId" label="单位"></el-table-column>
    <el-table-column prop="unitCost" label="单价"></el-table-column>
    <el-table-column prop="totalNum" label="数量"></el-table-column>
<el-table-column prop="stockId" label="仓库" width="120">
  <template slot-scope="scope">
    <span>{{ getStoreName(scope.row.stockId) }}</span>
  </template>
</el-table-column>
    <el-table-column prop="clientName" label="客户名称"></el-table-column>
    <el-table-column prop="documentNum" label="订单号"></el-table-column>
    <el-table-column prop="orderDate" label="订单日期"></el-table-column>
  </el-table-column>
 
  <el-table-column label="本次采购信息">
    <el-table-column prop="purchaseSaleDate" label="采购日期">
      <template slot-scope="scope">
        <el-date-picker
          v-model="scope.row.purchaseSaleDate"
          type="date"
          placeholder="选择日期">
        </el-date-picker>
      </template>
    </el-table-column>
    <el-table-column label="本次采购数量">
      <template slot-scope="scope">
        <el-input v-model="scope.row.hasbuy" placeholder="本次采购数量"></el-input>
      </template>
    </el-table-column>
    <el-table-column label="本次采购价格">
      <template slot-scope="scope">
        <el-input v-model="scope.row.price" placeholder="本次采购价格"></el-input>
      </template>
    </el-table-column>
  </el-table-column>
</el-table>



  </div>  

</template>

<script>
export default {
  data() {
    return {
  orders:[],
      form: {
        productCodeOrName: '',
        deliveryDate: '',
        salesOrderNumber: '',
        customer: '',
        pro:'',
        brand: '',
        showAvailableInventory: false,
        excludeCompletedOrders: false
      },
      dialogVisible: false,
      selectedCategory: '',
      searchQuery: '',
      showDisabled: false,
      supplier: [],
      selectedSuppliers: [],
storeList:[],
      dialogVisible2: false, // 控制弹窗显示
      searchQuery2: '', // 搜索查询
      showDisabled2: false, // 是否显示禁用客户
      currentPage: 1, // 当前页码
      pageSize: 10, // 每页显示条数
      totalCustomers: 0, // 总客户数
      customers: [], // 客户列表
      selectedCustomers: [] ,// 选中的客户


    };
  },
  methods: {
 getStoreList() {
  this.axios.get('/info/storeHouse/getAllStore', {
    params: {
      cId: 1
    }
  }).then(rs => {
    this.storeList = rs.data.storeList;
    console.log( this.storeList)
    // 确保 tableData 中的 stockId 与 storeList 中的 shId 匹配
   
  });
},
 getStoreName(stockId) {
    if (this.storeList) {
      const store = this.storeList.find(item => item.shId === stockId);
      return store ? store.storeHomeName : '未知仓库';
    }
    return '未知仓库';
  },
getlist(){
  this.axios({
    url:'/sale/saleOrderDetail/selectAll'
  }).then(rs=>{
    console.log(rs.data.list)
    this.orders=rs.data.list
  })
}
  },created(){
    this.getlist()
    this.getStoreList()
  }
}
</script>

<style scoped>
.table-container {
  overflow-x: auto;
}
.el-table {
  width: 100%;
}

</style>